/*
 * power-ss805x-priv.h
 *
 * The private definitions for power-ss805x.c.
 * Under normal conditions, it CAN be ignored by reader.
 *
 * Copyright (C) 2024 Sinh Micro, Inc.
 * Subject to the GNU Public License, version 2.
 *
 * Author: lixiang<lixiang@sinhmicro.com>
 * 
 * Encoding format: GB2312
 * Version: v1.2.2
 * Date: 2024-11-05
 */

#ifndef __POWER_SS805X_PRIV_H__
#define __POWER_SS805X_PRIV_H__

#include "hal-config.h"
#include "power.h"

#define  _MODE_SRC  POWER_WAKEUP_GET_MODE
#define  _OTH_SRC   POWER_WAKEUP_GET_OTHER_SRC
#define  _IO_SRC    POWER_WAKEUP_GET_IO_SRC

/*
 * DCIN sleep wakeup source
 */
#if (_OTH_SRC(CONFIG_POWER_SLP_WK_0) == POWER_WAKEUP_SOURCE_DCIN)
    #define _POWER_SLP_WK_DCIN_MODE     _MODE_SRC(CONFIG_POWER_SLP_WK_0)
#elif (_OTH_SRC(CONFIG_POWER_SLP_WK_1) == POWER_WAKEUP_SOURCE_DCIN)
    #define _POWER_SLP_WK_DCIN_MODE     _MODE_SRC(CONFIG_POWER_SLP_WK_1)
#elif (_OTH_SRC(CONFIG_POWER_SLP_WK_2) == POWER_WAKEUP_SOURCE_DCIN)
    #define _POWER_SLP_WK_DCIN_MODE     _MODE_SRC(CONFIG_POWER_SLP_WK_2)
#elif (_OTH_SRC(CONFIG_POWER_SLP_WK_3) == POWER_WAKEUP_SOURCE_DCIN)
    #define _POWER_SLP_WK_DCIN_MODE     _MODE_SRC(CONFIG_POWER_SLP_WK_3)
#elif (_OTH_SRC(CONFIG_POWER_SLP_WK_4) == POWER_WAKEUP_SOURCE_DCIN)
    #define _POWER_SLP_WK_DCIN_MODE     _MODE_SRC(CONFIG_POWER_SLP_WK_4)
#endif

/*
 * always timer sleep wakeup source
 */
#if (_OTH_SRC(CONFIG_POWER_SLP_WK_0) == POWER_WAKEUP_SOURCE_ATIMER)
    #define _POWER_SLP_WK_ATIMER_MODE     _MODE_SRC(CONFIG_POWER_SLP_WK_0)
#elif (_OTH_SRC(CONFIG_POWER_SLP_WK_1) == POWER_WAKEUP_SOURCE_ATIMER)
    #define _POWER_SLP_WK_ATIMER_MODE     _MODE_SRC(CONFIG_POWER_SLP_WK_1)
#elif (_OTH_SRC(CONFIG_POWER_SLP_WK_2) == POWER_WAKEUP_SOURCE_ATIMER)
    #define _POWER_SLP_WK_ATIMER_MODE     _MODE_SRC(CONFIG_POWER_SLP_WK_2)
#elif (_OTH_SRC(CONFIG_POWER_SLP_WK_3) == POWER_WAKEUP_SOURCE_ATIMER)
    #define _POWER_SLP_WK_ATIMER_MODE     _MODE_SRC(CONFIG_POWER_SLP_WK_3)
#elif (_OTH_SRC(CONFIG_POWER_SLP_WK_4) == POWER_WAKEUP_SOURCE_ATIMER)
    #define _POWER_SLP_WK_ATIMER_MODE     _MODE_SRC(CONFIG_POWER_SLP_WK_4)
#endif

/*
 * P03(SLPWK3) sleep wakeup source
 */
#if (_IO_SRC(CONFIG_POWER_SLP_WK_0) == 0x03)
    #define _POWER_SLP_WK_P03_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_0)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_1) == 0x03)
    #define _POWER_SLP_WK_P03_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_1)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_2) == 0x03)
    #define _POWER_SLP_WK_P03_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_2)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_3) == 0x03)
    #define _POWER_SLP_WK_P03_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_3)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_4) == 0x03)
    #define _POWER_SLP_WK_P03_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_4)
#endif

/*
 * P07(SLPWK7) sleep wakeup source
 */
#if (_IO_SRC(CONFIG_POWER_SLP_WK_0) == 0x07)
    #define _POWER_SLP_WK_P07_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_0)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_1) == 0x07)
    #define _POWER_SLP_WK_P07_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_1)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_2) == 0x07)
    #define _POWER_SLP_WK_P07_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_2)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_3) == 0x07)
    #define _POWER_SLP_WK_P07_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_3)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_4) == 0x07)
    #define _POWER_SLP_WK_P07_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_4)
#endif

/*
 * P10(SLPWK8) sleep wakeup source
 */
#if (_IO_SRC(CONFIG_POWER_SLP_WK_0) == 0x10)
    #define _POWER_SLP_WK_P10_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_0)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_1) == 0x10)
    #define _POWER_SLP_WK_P10_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_1)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_2) == 0x10)
    #define _POWER_SLP_WK_P10_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_2)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_3) == 0x10)
    #define _POWER_SLP_WK_P10_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_3)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_4) == 0x10)
    #define _POWER_SLP_WK_P10_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_4)
#endif

/*
 * P11(SLPWK9) sleep wakeup source
 */
#if (_IO_SRC(CONFIG_POWER_SLP_WK_0) == 0x11)
    #define _POWER_SLP_WK_P11_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_0)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_1) == 0x11)
    #define _POWER_SLP_WK_P11_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_1)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_2) == 0x11)
    #define _POWER_SLP_WK_P11_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_2)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_3) == 0x11)
    #define _POWER_SLP_WK_P11_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_3)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_4) == 0x11)
    #define _POWER_SLP_WK_P11_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_4)
#endif

/*
 * P12(SLPWK10) sleep wakeup source
 */
#if (_IO_SRC(CONFIG_POWER_SLP_WK_0) == 0x12)
    #define _POWER_SLP_WK_P12_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_0)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_1) == 0x12)
    #define _POWER_SLP_WK_P12_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_1)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_2) == 0x12)
    #define _POWER_SLP_WK_P12_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_2)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_3) == 0x12)
    #define _POWER_SLP_WK_P12_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_3)
#elif (_IO_SRC(CONFIG_POWER_SLP_WK_4) == 0x12)
    #define _POWER_SLP_WK_P12_MODE      _MODE_SRC(CONFIG_POWER_SLP_WK_4)
#endif

#define OTCON_INIT_VAL      (1 << 1)
#define LVDCON_INIT_VAL     ((0 << 1) |\ 
                             (1 << 0) |\
                             (3 << 5) |\ 
                             (1 << 4))

#endif
